package com.ningmengs789.live.ui.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.ningmengs789.live.R;
import com.ningmengs789.live.model.GoodslistDTO;

import java.util.List;

/**
 * 作者 : Administrator (yzhg)
 * 时间 : 2021-09-08 12:04
 * 包名 : com.ningmengs789.live.ui.adapter
 * 备注：
 */
public class DiscountGoodsAdapter extends BaseRecyclerViewAdapter{


    public DiscountGoodsAdapter(Context context, List data, int layoutId) {
        super(context, data, layoutId);
    }

    @Override
    protected void onBindData(RecyclerViewHolder holder, Object bean, int position) {

        GoodslistDTO goodslistDTO = (GoodslistDTO) bean;
        //商品图片
        ImageView limitDiscountIcon = holder.itemView.findViewById(R.id.iv_limit_discount_icon);
        //商品的标题
        TextView limitDiscountName = holder.itemView.findViewById(R.id.tv_limit_discount_name);
        //商品的价格
        TextView goodsPrice = holder.itemView.findViewById(R.id.tv_goods_price);


        //设置商品的图片
        RoundedCorners roundedCorners = new RoundedCorners(16);
        RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
        Glide.with(mContext)
                .load(goodslistDTO.getImageFrist())
                .apply(options)
                .into(limitDiscountIcon);


        //设置商品标题
        limitDiscountName.setText(goodslistDTO.getGoodsName());
        //设置商品价格
        goodsPrice.setText("¥ "+goodslistDTO.getSalesActual()+"");
    }
}
